import tkinter as tk
import  frame_remove_black
import  frame_tailor
import frame_merge
import AtlasToSprite
import GetPList_Visualization
import changeTXT
import ReSize_img
import set_anchor_pro
import set_anchor_pro_move
import ReSize_img_Org
import frame_tailor_move
import copyImage
def create_frame_with_title(parent, title, **kwargs):
    global frame
    # 创建边框Frame
    frame = tk.Frame(parent, padx=10, pady=10, relief='ridge', borderwidth=2)
    frame.grid_rowconfigure(0, weight=0)  # 标题行
    frame.grid_rowconfigure(1, weight=1)  # 按钮行
    frame.grid_columnconfigure(0, weight=1)  # 整列

    # 创建标题Label
    title_label = tk.Label(frame, text=title, anchor='w')  # 标题左对齐
    title_label.grid(row=0, column=0, sticky='w')

    # 由于我们只使用了一行，所以不需要额外处理多行情况
    # 但为了自适应，我们仍然配置了列的权重
    frame.grid_columnconfigure(0, weight=1)
    frame.grid_columnconfigure(1, weight=1)

    return frame

# 创建窗口
root = tk.Tk()
root.title("工具管理器")
root.config(bg="grey")
root.configure(background="#BCBCBC")


frame1 = create_frame_with_title(root, "序列帧图片工具")
frame1.grid(row=0, column=0, sticky="nsew", pady=5)

def oppen_frame_remove_black():
    frame_remove_black.create_window(root)

def oppen_frame_tailor():
    #frame_tailor.create_window(root)
    frame_tailor_move.create_window(root)

def oppen_frame_merge():
    frame_merge.create_window(root)

def oppen_AtlasToSprite():
    AtlasToSprite.create_window(root)

def oppen_resize_img():
    ReSize_img.create_window(root)

def oppen_plist():
    GetPList_Visualization.create_window(root)

def oppen_text_image():
    changeTXT.create_window(root)

def oppen_set_anchor():
    set_anchor_pro.create_window(root)

def oppen_anchor_pro_move():
    set_anchor_pro_move.create_window(root)

def oppen_resize_img_org():
    ReSize_img_Org.create_window(root)

def oppen_copy():
    copyImage.create_window(root)


button1 =tk.Button(frame, text="序列帧图片去黑底器", command=oppen_frame_remove_black, bg='skyblue')
button1.grid(row=1, column=0, sticky="nsew",  padx=5, pady=5)  # 按钮从第二行开始

button2 =tk.Button(frame, text="序列帧图片裁剪器", command=oppen_frame_tailor, bg='skyblue')
button2.grid(row=1, column=1, sticky="nsew", padx=5, pady=5)  # 按钮从第一行 第二列开始
#
# button3 =tk.Button(frame, text="序列帧图片合并器", command=oppen_frame_merge, bg='skyblue')
# button3.grid(row=2, column=0, sticky="nsew", padx=5, pady=5)

button4 =tk.Button(frame, text="json切图", command=oppen_AtlasToSprite, bg='skyblue')
button4.grid(row=2, column=0, sticky="nsew", padx=5, pady=5)

# button5 =tk.Button(frame, text="序列帧图片缩放器", command=oppen_resize_img, bg='skyblue')
# button5.grid(row=3, column=0, sticky="nsew", padx=5, pady=5)

button6 =tk.Button(frame, text="996切割plist", command=oppen_plist, bg='skyblue')
button6.grid(row=2, column=1, sticky="nsew", padx=5, pady=5)

button7 =tk.Button(frame, text="txt生成图片", command=oppen_text_image, bg='skyblue')
button7.grid(row=3, column=0, sticky="nsew", padx=5, pady=5)

# button8 =tk.Button(frame, text="序列帧修改器", command=oppen_set_anchor, bg='skyblue')
# button8.grid(row=4, column=1, sticky="nsew", padx=5, pady=5)

button8 =tk.Button(frame, text="锚点调整工具", command=oppen_anchor_pro_move, bg='skyblue')
button8.grid(row=3, column=1, sticky="nsew", padx=5, pady=5)

button8 =tk.Button(frame, text="原尺寸缩放工具", command=oppen_resize_img_org, bg='skyblue')
button8.grid(row=4, column=0, sticky="nsew", padx=5, pady=5)

button9 =tk.Button(frame, text="大图切割工具", command=oppen_copy, bg='skyblue')
button9.grid(row=4, column=1, sticky="nsew", padx=5, pady=5)


root.mainloop()